package com.xyy.saas.payment.adpater.abchinaLoan.core.req;

import com.xyy.saas.payment.common.exception.PayBizException;
import com.xyy.saas.payment.cores.enums.ResultCodeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author wangzeqi
 */
@Data
@Accessors(chain = true)
public class ApplyH5Dto {

    /**
     * 企业统一信用代码
     */
    private String uscc;

    /**
     * 企业名称
     */
    private String unitName;

    /**
     * 药店在药帮忙平台注册时间
     * yyyy-MM-dd HH:mm:ss
     */
    private String registerTime;


    public static ApplyH5Dto mock() {
        return new ApplyH5Dto()
                .setUscc("uscYBM100")
                .setUnitName("小药药有限公司")
                .setRegisterTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    }


    public void checkParam() {
        if (StringUtils.isBlank(uscc) || StringUtils.isBlank(unitName) || StringUtils.isBlank(registerTime)) {
            throw new PayBizException(ResultCodeEnum.PARAM_ERROR);
        }
    }


}
